package com.bricks2break;

import com.screens.StartMenu;

import sheep.game.Game;
import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;

/**
 * 
 * This is the activity class.
 *
 */
public class Bricks2Break extends Activity {
    /**
     * Create the objects.
     */
	public Game game;
	public StartMenu startmenu;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		Create the game.
		game = new Game(this, null);

//		Set up Statics
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);

		Statics.SCREEN_HEIGHT= dm.heightPixels;
		Statics.SCREEN_WIDTH = dm.widthPixels;
		Statics.POSITION_PADDLE_BOTTOM=Statics.SCREEN_HEIGHT-Statics.POSITION_PADDLE_TOP;
		Statics.POSITION_BRICK_SPAWN_TOP=Statics.SCREEN_HEIGHT/2-Statics.DISTANCE_FROM_CENTER;
		Statics.POSITION_BRICK_SPAWN_BOTTOM=Statics.SCREEN_HEIGHT/2+Statics.DISTANCE_FROM_CENTER;
		
		//Set fullscreen
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		startmenu = new StartMenu();
		
		//View the start menu
		game.pushState(startmenu);
		setContentView(game);

	}
    
	/**
	 * Defines what happens when the activity is stopped.
	 */
    public void onStop(){
    	super.onStop();
    }
    /**
     * Defines what happens when the activity is destroyed.
     */
    public void onDestroy(){
    	super.onDestroy();
    }
    
    /**
     * Return to start menu when back key is pressed
     */
    public void onBackPressed(){
		game.popState();
		if(game.getPreviousState()==null){
			game.pushState(startmenu);	
		}
		
	}
}